CXX-3288 do not initialize ENABLE_TESTS with the auto-downloaded C Driver #1404
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves CXX-3288. Split from #1403.
This PR delays the call to
include(FetchMongoC)
until after all top-level cache variables have been initialized (notably, including theENABLE_TESTS
option) to avoid the C Driver's own cache variable initialization taking priority over the C++ Driver when conditionally importing the auto-downloaded C Driver viaadd_subdirectory()
.The auto-downloaded C Driver is observed to overwrite the default value (OFF) of the C++ Driver's
ENABLE_TESTS
cache variable with its own default (ON):According to CMake documentation,
set()
shouldn't overwrite an existing cache variable:The C++ Driver defines
ENABLE_TESTS
viaoption()
, which creates a cache variable:However, the C++ Driver does so long after the C Driver has already been imported via
include(FetchMongoC)
. This means the C Driver'sENABLE_TESTS
cache variable initialization viaset(CACHE)
has priority over the C++ Driver's call tooption()
which is therefore ignored:To fix this bug, this PR moves the
include(FetchMongoC)
to come afteroption(ENABLE_TESTS)
(and other top-level cache variables) and just beforeadd_subdirectory(src)
(where C Driver targets are required).